Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#567 add test suite #573

Merged
merged 7 commits into from
May 28, 2024
Merged

#567 add test suite #573

merged 7 commits into from
May 28, 2024

Conversation

murny
Copy link
Collaborator

@murny murny commented May 4, 2024

Attempt at adding a few smoke tests just to verify the CMS is running correctly.

This will hopefully add a pattern we can build off in the future.

This also adds a very simple CI runner that will run these tests.

@murny murny changed the base branch from master to upgrade-mariadb-docker-version May 4, 2024 02:49
@murny murny changed the base branch from upgrade-mariadb-docker-version to master May 6, 2024 17:13
@@ -1,12 +1,54 @@
tmp/
Copy link
Collaborator Author

@murny murny May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We weren't gitignoring log/test.log, so instead of just adding this, I brought in the .gitignore from a fresh rails app and refactored this a bit (our "custom" ones are at the bottom with some comments).

get comfy_cms_render_page_path(cms_path: 'hours-locations')

assert_response :success
assert_select "h1", /Hours & Locations/
Copy link
Collaborator Author

@murny murny May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The H1 tag on these pages has a lot of extra information in it, such as links and other things.

So for example for the "About us" page, you can see in this photo the links on the right is actually inside the <H1>:
image

So using a regex to just extract and assert the actual header content here.

This could probably be improved by moving the extra info outside of the header tag.

@@ -0,0 +1,71 @@
name: CI
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

branches: [ main ]

jobs:
# lint:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will like to add rubocop to the project later, so just stubbing this out for now

@@ -2,6 +2,14 @@
require_relative '../config/environment'
require 'rails/test_help'

# Seed the database with our CMS seed data, if it's not already there
Copy link
Collaborator Author

@murny murny May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes here:

This will seed the test DB with our CMS data BEFORE the tests run, so it's technically outside the transactions that normally happen in the test suite. This is good because, every time we run tests, we don't need to reseed the DB (as this seeding is expensive, and takes a good ~30 seconds as we have many, many pages). It's bad in the case of what happens when the seed data changes? These changes won't be available right away, and will likely require someone to manually drop the test DB. But I assume changing the seed data is a rare occurrence.

I also tried to move this to a rake task but was having issues with Comfy not being available.

Typically, we should be using fixtures here and following Comfy best practice here, which is to have a minimal version of our website for testing:
https://github.com/comfy/comfortable-mexican-sofa/wiki/HowTo:-Minimal-Fixtures-For-Testing

Or we can parse down the amount of CMS pages we have? As it appears, we have a ton of redundant/old pages or multiple versions (sandbox/french) of our CMS.

The less we have, the faster the seeding can take place, which means we could in theory just use fixtures and seed the CMS every time before the tests run, which means we could get the best of both worlds.

@murny murny marked this pull request as ready for review May 6, 2024 22:12
Copy link
Member

@pgwillia pgwillia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start on smoke tests and a good structure to build on.


# Our custom ignores
.DS_Store
# This is ignored due to Ansible I assume:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume too.


require "test_helper"

class CmsTest < ActionDispatch::IntegrationTest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done later, but it would be good to cover the features noted in the readme:

  • home page
  • staff (view, new and edit)
  • admin

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that sounds like a good idea, especially Staff as this is custom (not part of the CMS) 👍. So will add a note to add more tests for this here #567

@murny murny mentioned this pull request May 28, 2024
@murny murny merged commit e6aeaba into master May 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants